<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="ctx" value="${pageContext.request.contextPath}" />

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8"> 
  <meta name="”renderer”" content="”webkit”"> 
  <meta http-equiv="”X-UA-Compatible”" content="”IE=Edge,chrome=1″"> 
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> 
  <title>乐直播-直播活动</title> 
  <link rel="stylesheet" href="http://cdn.lezhibo.com/staticRep/layui/css/layui.css?cdnv=0.16"> 
  <link rel="stylesheet" href="http://cdn.lezhibo.com/static/portal/css/le-main24.css?cdnv=0.16"> 
  <link rel="stylesheet" href="http://cdn.lezhibo.com/static/libs/font-awesome/css/font-awesome.min.css?cdnv=0.16"> 
  <style type="text/css">
.activity-span1{
position: absolute;
top: 2px;
right: 2px;
padding: 4px 10px;
font-size: 10px;
color: #fff;
border-radius: 13px;
background-color:#f08300;
opacity:0.5;
}
.activity-span2{
position: absolute;
top: 2px;
right: 2px;
padding: 4px 10px;
font-size: 10px;
color: #fff;
border-radius: 13px;
background-color:rgba(0,0,0,0.5);
}
        </style> 
  <script src="http://cdn.lezhibo.com/static/portal/js/fastclick.js?cdnv=0.16"></script> 
 </head> 
 <body> 
  <div class="le-main"> 
<%@include file="portal_navi.jsp" %>
   </div> 
  </div> 
  <div class="le-head-content"> 
   <form class="layui-form le-live-right" action="${ctx }/portal/room.vo" method="get"> 
    <div class="layui-input-inline"> 
     <button type="submit" class="layui-btn layui-btn-primary">搜索</button> 
    </div> 
    <div class="layui-input-inline"> 
     <input type="text" name="title" value="" lay-verify="phone" autocomplete="off" placeholder="输入活动名" class="layui-input"> 
    </div> 
    <div class="layui-input-inline le-live-time" style="margin-right:10px;"> 
     <input type="text" name="date2" id="end-date" value="" lay-verify="date" placeholder="截止日" readonly autocomplete="off" class="layui-input end-date"> 
    </div> 
    <div class="le-live-info">
     至
    </div> 
    <div class="layui-input-inline le-live-time"> 
     <input type="text" name="startDate" id="begin-date" value="" lay-verify="date" placeholder="开始日" readonly autocomplete="off" class="layui-input begin-date"> 
    </div> 
    <div class="le-live-info">
     时间：
    </div> 
   </form> 
   <ul class="le-live-content"> 
    <li class="le-add-hardware" layer-href="${ctx }/portal/activity/add.vo" layer-func="layerBack()" style="width:23%;"> <a class="le-hardware-link" href="#"> <p><i class="fa fa-plus-circle fa-5x" aria-hidden="true"></i></p> <h3>新建活动</h3> </a> </li>
    <c:if test="${not empty pageResult}">
        <c:forEach items="${pageResult.info }" var="activity">
            <c:forEach items="${activity.cases }" var="caseDetail">
                <li class="live-hover" style="width:23%;" go-href="${ctx }/portal/activity.vo?id=${caseDetail.id}" go-href-new="true"> 
                 <div class="live-up2"> 
                  <div class="live-position"> 
                   <div class="live-position-describe"> 
                    <p class="live-position-left">免费观看</p> 
                    <p class="live-position-right"> <span><i class="fa fa-comments-o" aria-hidden="true"></i>${caseDetail.commentCount}</span> <span><i class="fa fa-eye" aria-hidden="true"></i>${caseDetail.accessCount }</span> </p> 
                   </div> 
                  </div> 
                  <div class="le-hardware-img2"> 
                   <img src="" class="lazy" data-original="http://cdn.lezhibo.com/static/portal/images/activity-default.jpg"> 
                  </div> 
                 </div> 
                 <div class="live-down2"> 
                  <h2>${caseDetail.title }</h2> 
                 </div> </li> 
            </c:forEach>
        </c:forEach>
    </c:if>
    <li class="live-hover" style="width:23%;" go-href="${ctx }/portal/activity.vo?id=a4e0d3a517e4441087bb899354ab698c" go-href-new="true"> 
     <div class="live-up2"> 
      <div class="live-position"> 
       <div class="live-position-describe"> 
        <p class="live-position-left"> 免费观看 </p> 
        <p class="live-position-right"> <span><i class="fa fa-comments-o" aria-hidden="true"></i>0</span> <span><i class="fa fa-eye" aria-hidden="true"></i>5</span> </p> 
       </div> 
      </div> 
      <div class="le-hardware-img2"> 
       <img src="" class="lazy" data-original="http://cdn.lezhibo.com/static/portal/images/activity-default.jpg"> 
      </div> 
     </div> 
     <div class="live-down2"> 
      <h2>测试</h2> 
     </div> </li> 
    <li class="live-hover" style="width:23%;" go-href="/portal/activity.vo?id=1dee5b359e6e42c4822d1af3c8a35b86" go-href-new="true"> 
     <div class="live-up2"> 
      <div class="live-position"> 
       <div class="live-position-describe"> 
        <p class="live-position-left"> 密码观看 </p> 
        <p class="live-position-right"> <span><i class="fa fa-comments-o" aria-hidden="true"></i>0</span> <span><i class="fa fa-eye" aria-hidden="true"></i>6</span> </p> 
       </div> 
      </div> 
      <div class="le-hardware-img2"> 
       <img src="" class="lazy" data-original="http://cdn.lezhibo.com/attachment/20170818/c3ef864d5aec461d9f5b615d61c2c31e.jpg"> 
      </div> 
     </div> 
     <div class="live-down2"> 
      <h2>乐直播直播间</h2> 
     </div> </li> 
    <li class="live-hover" style="width:23%;" go-href="/portal/activity.vo?id=a67bb59f9374440f94efa687b8548c24" go-href-new="true"> 
     <div class="live-up2"> 
      <div class="live-position"> 
       <div class="live-position-describe"> 
        <p class="live-position-left"> 免费观看 </p> 
        <p class="live-position-right"> <span><i class="fa fa-comments-o" aria-hidden="true"></i>6</span> <span><i class="fa fa-eye" aria-hidden="true"></i>41</span> </p> 
       </div> 
      </div> 
      <div class="le-hardware-img2"> 
       <img src="" class="lazy" data-original="http://cdn.lezhibo.com/attachment/20170712/83c60a3572b64f71990bef2f00001075.png"> 
      </div> 
     </div> 
     <div class="live-down2"> 
      <h2>天创恒达上海分部</h2> 
     </div> </li> 
    <li class="live-hover" style="width:23%;" go-href="/portal/activity.vo?id=9f0a7942491543ecb35c6e55a57cb83b" go-href-new="true"> 
     <div class="live-up2"> 
      <div class="live-position"> 
       <div class="live-position-describe"> 
        <p class="live-position-left"> 免费观看 </p> 
        <p class="live-position-right"> <span><i class="fa fa-comments-o" aria-hidden="true"></i>127</span> <span><i class="fa fa-eye" aria-hidden="true"></i>300</span> </p> 
       </div> 
      </div> 
      <div class="le-hardware-img2"> 
       <img src="" class="lazy" data-original="http://cdn.lezhibo.com/attachment/20170710/271586d2206d4761975f202923a48305.jpg"> 
      </div> 
     </div> 
     <div class="live-down2"> 
      <h2>天创恒达上海分部</h2> 
     </div> </li> 
    <li class="live-hover" style="width:23%;" go-href="/portal/activity.vo?id=04813844a39649519aa0f84a33166660" go-href-new="true"> 
     <div class="live-up2"> 
      <div class="live-position"> 
       <div class="live-position-describe"> 
        <p class="live-position-left"> 免费观看 </p> 
        <p class="live-position-right"> <span><i class="fa fa-comments-o" aria-hidden="true"></i>0</span> <span><i class="fa fa-eye" aria-hidden="true"></i>13</span> </p> 
       </div> 
      </div> 
      <div class="le-hardware-img2"> 
       <img src="" class="lazy" data-original="http://cdn.lezhibo.com/attachment/20170617/49b5d6b4b40f4dca9245c96e32788b65.jpg"> 
      </div> 
     </div> 
     <div class="live-down2"> 
      <h2>ceshi</h2> 
     </div> </li> 
    <li class="live-hover" style="width:23%;" go-href="/portal/activity.vo?id=75ce1d32a3d74de68cef03ad3f132588" go-href-new="true"> 
     <div class="live-up2"> 
      <div class="live-position"> 
       <div class="live-position-describe"> 
        <p class="live-position-left"> 免费观看 </p> 
        <p class="live-position-right"> <span><i class="fa fa-comments-o" aria-hidden="true"></i>0</span> <span><i class="fa fa-eye" aria-hidden="true"></i>9</span> </p> 
       </div> 
      </div> 
      <div class="le-hardware-img2"> 
       <img src="" class="lazy" data-original="http://cdn.lezhibo.com/attachment/20170726/92868397339041d99048a6f721fb7109.gif"> 
      </div> 
     </div> 
     <div class="live-down2"> 
      <h2>信号测试</h2> 
     </div> </li> 
    <li class="live-hover" style="width:23%;" go-href="/portal/activity.vo?id=98d28db0b1144b44a86b60db5c1da9b0" go-href-new="true"> 
     <div class="live-up2"> 
      <div class="live-position"> 
       <div class="live-position-describe"> 
        <p class="live-position-left"> 免费观看 </p> 
        <p class="live-position-right"> <span><i class="fa fa-comments-o" aria-hidden="true"></i>2</span> <span><i class="fa fa-eye" aria-hidden="true"></i>16</span> </p> 
       </div> 
      </div> 
      <div class="le-hardware-img2"> 
       <img src="" class="lazy" data-original="http://cdn.lezhibo.com/attachment/20170418/68b840313143463994f389e363b8b766.jpg"> 
      </div> 
     </div> 
     <div class="live-down2"> 
      <h2>大家一起来直播</h2> 
     </div> </li> 
   </ul> 
   <div class="le-pages"> 
   <c:set var="currPage" value="${ 0 lt pageResult.pageInfo.currPage ? pageResult.pageInfo.currPage - 1 : 0}" />
       <c:set var="nextPage" value="${ pageResult.pageInfo.currPage lt pageResult.pageInfo.totalPage ? pageResult.pageInfo.currPage + 1 : pageResult.pageInfo.currPage}" />
    <a href="${ctx }/portal/room.vo?currPage=${currPage}" class="previous disabled">上一页</a> 
    <a href="${ctx }/portal/room.vo?currPage=${pageResult.pageInfo.currPage}" class="active">${pageResult.pageInfo.currPage+1 }</a> 
    <a href="${ctx }/portal/room.vo?currPage=${nextPage}" class="next disabled">下一页</a> 
   </div> 
   <div class="clearfix"></div> 
  </div> 
  <script type="text/javascript" src="http://cdn.lezhibo.com/staticRep/layui/layui.js?cdnv=0.16"></script> 
  <script type="text/javascript" src="http://cdn.lezhibo.com/staticRep/layui/lay/dest/layui.all.js?cdnv=0.16"></script> 
  <script type="text/javascript" src="http://cdn.lezhibo.com/static/libs/jquery/jquery.min.js?cdnv=0.16"></script> 
  <script type="text/javascript" src="http://cdn.lezhibo.com/static/libs/jquery/jquery.form.min.js?cdnv=0.16"></script> 
  <script>
            var cdnPath="http://cdn.lezhibo.com";//cdn路径
            function fix() {
                var head_height = $('.le-head').outerHeight();
                var window_height = $(window).height();
                var content_height = $('.le-content').outerHeight();
                var sidebar_height = $(".le-sidebar").height();
                var max_height = window_height - head_height;
                if(content_height < sidebar_height){
                    content_height = sidebar_height;
                }

                if(max_height < content_height){
                    max_height = content_height;
                }

                $(".le-content").css('min-height', max_height);
                $(".le-sidebar").css('min-height', max_height);


//                if (content_height < (window_height - head_height)) {
//                    $(".le-content").css('min-height', window_height - head_height);
//                } else {
//                    $(".le-sidebar").css('min-height', content_height);
//                    sidebar_height = content_height;
//                }
//
//                if (sidebar_height < (window_height - head_height)) {
//                    $(".le-sidebar").css('min-height', window_height - head_height);
//                }
            }

            var globalNeedRefreshIndex = "";
            var globalNeedRefreshUrl = "";
            var needRefresh = false;

            function openLayer(url, title, func, isNeedRefreshThisPage) {
                var index = layer.open({
                    type: 2,
                    title: title,
                    shadeClose: true,
                    shade: 0.6,
                    area: ['60%', '80%'],
                    content: url,
                    end: function () {
                        if (needRefresh) {
                            layer.iframeSrc(globalNeedRefreshIndex, globalNeedRefreshUrl);//刷新第几层
                            needRefresh = false;
                        }

                        if (!(typeof(func) == "undefined")) {
                            eval(func);
                        }
                    }
                });

                if (isNeedRefreshThisPage == true) {
                    globalNeedRefreshIndex = index;
                    globalNeedRefreshUrl = url;
                }

            }

            function layerInit() {
                $("[layer-href]").click(function () {
                    if ("" == $(this).attr("layer-need-record")) {
                        openLayer($(this).attr("layer-href"), $(this).attr("layer-title"), $(this).attr("layer-func"), true);
                    } else {
                        openLayer($(this).attr("layer-href"), $(this).attr("layer-title"), $(this).attr("layer-func"), false);
                    }
                });

                $("[go-href]").click(function () {
                    var href = $(this).attr("go-href");
                    var newWind = $(this).attr("go-href-new");
                    if (newWind == "true") {
                        window.open(href);
                    } else {
                        window.location.href = href;
                    }
                });


                $("[confirm-href]").click(function () {
                    var href = $(this).attr("confirm-href");
                    if ((typeof(href) == "undefined") || href == null || href == "") {
                        return;
                    }

                    var title = $(this).attr("confirm-title");
                    if ((typeof(title) == "undefined") || title == null || title == "") {
                        title = "您确定执行该操作吗？"
                    }
                    layer.confirm(title, {icon: 9, title: '确定操作 ？'}, function (index) {
                                layer.close(index);
                                $.get(href, function (result) {
                                    if (result.isOk) {
                                        location.reload();
                                    } else {
                                        alert(result.message);
                                    }
                                });
                            },
                            function (index) {
                                layer.close(index);
                            });
                });


            }

            function headerFocus() {
                $("#nav-index").addClass("layui-this");
            }


            function initSidebarUrls() {

                $(".le-sidebar").find(".layui-nav-item").each(function () {
                    var pid = $(this).attr("id");
                    if (typeof(pid) == 'undefined' || null == pid) {
                        return;
                    }

                    var href = $(this).children('a').attr("href");
                    if ((typeof(href) != "undefined") && href.indexOf("?") == -1) {
                        href = href + "?p=" + pid;
                    } else {
                        href = href + "&p=" + pid;
                    }
                    $(this).attr("class", "layui-nav-item");
                    $(this).children('a').attr("href", href);
                });

                $("#").attr("class", "layui-nav-item layui-this");
            }

            var verification = {
                mobiel: function () {
                    $mobile = $("input[validate='mobile']").val();
                    var re = /^1\d{10}$/;
                    if ((typeof($mobile) != "undefined") && !re.test($mobile)) {
                        $("input[validate='mobile']").after('<p class="le-tips"><span style="color: red;width: 100%">请输入正确的手机号</span></p>');
                        return false;
                    }
                },
                email: function () {
                    $email = $("input[validate='email']").val();
                    var re = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
                    if ((typeof($email) != "undefined") && !re.test($email)) {
                        $("input[validate='email']").after('<p class="le-tips"><span style="color: red;width: 100%">请输入正确的邮箱</span></p>');
                        return false;
                    }
                },
                empty: function () {
                    var $input = $("input[validate='empty']");
                    for (var i = 0; i < $input.length; i++) {
                        if ($input.eq(i).val().trim().length == 0) {
                            $("input[validate='empty']").eq(i).after('<p class="le-tips"><span style="color: red;width: 100%">输入不能为空</span></p>');
                            return false;
                        }
                    }

                    var $textarea =$("textarea[validate='empty']");
                    for(var i=0;i<$textarea.length;i++){
                        if($textarea.eq(i).val().trim().length==0){
                            $("textarea[validate='empty']").eq(i).after('<p class="le-tips"><span style="color: red;width: 100%">输入不能为空</span></p>');
                            return false;
                        }
                    }
                },

                password: function () {
                    $password = $("input[validate='password']").val();
                    var re = /(.+){6,12}$/;
                    if ((typeof($password) != "undefined") && !re.test($password)) {
                        $("input[validate='password']").after('<p class="le-tips"><span style="color: red;width: 100%">请输入6到12位密码</span></p>');
                        return false;
                    }
                },
                //正整数
                positiveInteger: function () {
                    $positiveInteger = $("input[validate='positiveInteger']");
                    var re=/^[1-9]\d*|0$/;
                    for (var i = 0; i < $positiveInteger.length; i++) {
                        var every=$positiveInteger.eq(i).val().trim();
                        if ((typeof(every) != "undefined") && !re.test(every)) {
                            $("input[validate='positiveInteger']").eq(i).after('<p class="le-tips"><span style="color: red">请输入一个正整数或者0</span></p>');
                            return false;
                        }
                    }
                },
                decimal: function (value) {
                   $decimal = $("input[validate='decimal']");
                    var re = /^[0-9]+\.{0,1}[0-9]{0,2}$/;
                    for (var i = 0; i < $decimal.length; i++) {
                        var every=$decimal.eq(i).val().trim();
                        if ((typeof(every) != "undefined") && !re.test(every)) {
                            $("input[validate='decimal']").eq(i).after('<p class="le-tips"><span style="color: red">值不能小于0</span></p>');
                            return false;
                        }
                    }
                }
            };


            var regularVerify = {
                mobile: function (value) {
                    var re = /^1\d{10}$/;
                    if ((typeof(value) != "undefined") && !re.test(value)) {
                        return false;
                    }
                },
                email: function (value) {
                    var re = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
                    if ((typeof(value) != "undefined") && !re.test(value)) {
                        return false;
                    }
                },
                password: function (value) {
                    var re = /(.+){6,12}$/;
                    if ((typeof(value) != "undefined") && !re.test(value)) {
                        return false;
                    }
                },
                integer: function (value)     {
//                    var re = /^[1-9]\d*$/;
                    var re = /^\d+$/;
                    if ((typeof(value) != "undefined") && !re.test(value)) {
                        return false;
                    }
                },
                decimal: function (value) {
//                    var re = /^[1-9]\d*\.\d*|0\.\d*[1-9]\d*$/;
                    var re = /^[0-9]+\.{0,1}[0-9]{0,2}$/;
                    if ((typeof(value) != "undefined") && !re.test(value)) {
                        return false;
                    }
                },
                empty: function (value) {
                    if (value.trim().length == 0) {
                        return false;
                    }
                }
            }


            function leSubmit() {
                $("[le-submit]").click(function () {
                    var $form = $(this).parents("form");
                    var sfunc = $form.attr("success-func");
                    var bfunc = $form.attr("before-func");
                    $form.ajaxSubmit({
                        type: "post",
                        dataType: "json",
                        beforeSend: function () {
                            if(bfunc != null){
                                if(false == eval(bfunc)){
                                    return false;
                                }
                            }
                            $(".le-tips").remove();
                            if (false == verification.empty()) {
                                return false;
                            }
                            if (false == verification.mobiel()) {
                                return false;
                            }
                            if (false == verification.email()) {
                                return false;
                            }
                            if (false == verification.password()) {
                                return false;
                            }
                        },
                        success: function (result) {
                            if (sfunc != null) {
                                eval(sfunc);
                                return;
                            }

                            if (result.isOk) {
                                parent.isUpdateData = true;
                                parent.layer.closeAll();
                            } else {
                                alert(result.message);
                            }
                        },
                        error: function () {
                            alert("信息提交错误");
                        }
                    });
                })
            }

            //对日期选择范围的控制
            //对id为begin-date和end-date的日期选择控件进行控制
            function verifyDate() {
                layui.use('laydate', function () {
                    var laydate = layui.laydate;
                    var start = {
                        min: '2006-01-01 00:00:00',
                        max: '2099-06-16 23:59:59',
                        istoday: false,
                        choose: function (datas) {
                            end.min = datas;    //开始日选好后， 重置结束日的最小日期
                            end.start = datas;  //将结束日的初始值设定为开始日
                        }
                    };

                    var end = {
                        min: '2006-01-01 00:00:00',
                        max: '2099-06-16 23:59:59',
                        istoday: false,
                        choose: function (datas) {
                            start.max = datas;  //结束日选好后, 重置开始日的最大日期
                        }
                    };

                    $('.begin-date').click(function () {
                        start.elem = this;
                        laydate(start);
                    });
                    $('.end-date').click(function () {
                        end.elem = this;
                        laydate(end);
                    });

                });
            }

            fix();
            layerInit();
            headerFocus();
            initSidebarUrls();
            leSubmit();
            verifyDate();



    var isUpdateData = false;
    function layerBack(){
        if(isUpdateData)
        {
            isUpdateData = false;
            location.reload();
        }
    }
    $(function() {
        //用oss处理图片，加快图片加载速度
        $("img.lazy").each(function () {
            var resizedImgSrc = $(this).attr("data-original") + '?x-oss-process=image/resize,m_fill,h_' + $(this).height() + ',w_' + $(this).width() + ',limit_0';
            $(this).attr("src", resizedImgSrc);
        });
    });


        </script>   
 </body>
</html>